package test.cluster.net.connector;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IoSession;

import test.cluster.ResultPacket;

public class ConnectorSessionHandler extends IoHandlerAdapter {
	private Log log = LogFactory.getLog(this.getClass());
	
	@Override
	public void exceptionCaught(IoSession session, Throwable cause)
			throws Exception {
		cause.printStackTrace();
		session.close(true);
	}

	@Override
	public void messageReceived(IoSession session, Object message)
			throws Exception {
		if (message instanceof ResultPacket) {
			log.info("result has been arrived.");
		}
	}
}
